﻿@model Icms.WebUI.Dto.ParticipantEditInput
<div class='ia'>
    @Html.EditorFor(o => o.Type)
    @Html.EditorFor(o => o.PersonId)
    @Html.EditorFor(o => o.TypePartyId)
    <div id='inculpat'>
        @Html.EditorFor(o => o.PleaBargain)
        @Html.EditorFor(o => o.Minor)
        @Html.EditorFor(o => o.CitizenshipId)
        @Html.EditorFor(o => o.CatId)
    </div>
    @Html.EditorFor(o => o.Idnp)
    @Html.EditorFor(o => o.LastName)
    <div class='fizica'>
        @Html.EditorFor(o => o.FirstName)
        @Html.EditorFor(o => o.SurName)
        @Html.EditorFor(o => o.DateOfBirth)
        @Html.EditorFor(o => o.Gender)
    </div>
</div>
<div class='ia'>
    @Html.EditorFor(o => o.Stranger)
    <div id="cregionid">
        @Html.EditorFor(o => o.RegionId)
    </div>
    <div id='cregion'>
        @Html.EditorFor(o => o.Region)
    </div>
    @Html.EditorFor(o => o.Location)
    @Html.EditorFor(o => o.Street)
    @Html.EditorFor(o => o.Home)
    @Html.EditorFor(o => o.Appartment)
    @Html.EditorFor(o => o.Phone)
    @Html.EditorFor(o => o.CellPhone)
    @Html.EditorFor(o => o.Email)
    @Html.EditorFor(o => o.ContactInfo)
</div>
<div class='ia'>
<div class='fizica'>
    @Html.EditorFor(o => o.OccupationId)
    @Html.EditorFor(o => o.EducationId)
    @Html.EditorFor(o => o.Function)
    @Html.EditorFor(o => o.TypeActivity)
</div>
    @Html.EditorFor(o => o.Comments)
</div>
<script type="text/javascript">
    function stranger() {
        if ($(this).is(':checked')) {
            $('#cregionid').hide();
            $('#cregion').show();
        }
        else {
            $('#cregionid').show();
            $('#cregion').hide();
        }
    }

    function defendant() {
        if ($('#TypePartyId').val() == '@Const.defendant')
            $('#inculpat').show();
        else
            $('#inculpat').hide();
    }

    function fizica() {
        if ($('#Type').val() == 'j')
            $('.fizica').hide();
        else
            $('.fizica').show();
    }

    $(function () {
        $('#Stranger').click(stranger);
        $('#TypePartyId').change(defendant);
        $('#Type').change(fizica);
        stranger();
        defendant();
        fizica();
        $('#PersonId').change(function () {
            $.post('@Url.Action("GetPerson", "Aja")', { id: $('#PersonId').val() }, function (o) {
                $.each(o, function (k, v) {
                    if (k == 'DateOfBirth') {
                        var d = new Date(parseInt(v.replace("/Date(", "").replace(")/", ""), 10));
                        $('#' + k).val(d.getDate() +'.' + d.getMonth()+'.'+d.getFullYear());
                    }
                    else if (k != 'PersonId' && k != "Id") {
                        $('#' + k).val(v).change();
                        $('#' + k + 'dropdown').val(v).change();
                    }
                });
            });
        });
    });
</script>
